package com.docker.mq.rabbitmqclient.consumer;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class Consumer {

    private static final Logger logger = LoggerFactory.getLogger(Consumer.class);

    // 监听队列
    @RabbitListener(queues = "boot_queue")
    public void listenMessage(String jString){
        // 使用日志框架记录信息
        logger.info("接收消息：{}", jString);
        if (jString == null || jString.isEmpty()) {
            logger.error("接收到的消息为空");
            return; // 防止空消息导致的异常
        }
        System.out.println(jString);

    }

}
